package org.kent.w.base.common.validate;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Validate Result
 *
 * @author wujigang
 * @date 2019/9/17
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ValidateResult implements Serializable {

    private boolean success;

    private Map<String, String> messageMap;

    public void addMessage(String propertyName, String message) {

        if (null == messageMap) {
            messageMap = new HashMap<>();
        }

        messageMap.put(propertyName, message);
    }
}
